CHARTS
Photo by Sebastian Santacruz on Unsplash
Everybody wants to save the earth; no one wants to help mom do the dishes…
— P.J. O’Rourke
# Load data
url_root <- "https://raw.githubusercontent.com/UN-AVT/kamino-source/main/sources/0-shared/data/"
url_file <- "unpaid-care-and-domestic-work-by-region/unpaid-care-and-domestic-work-by-region.csv"
url <- paste0(url_root, url_file)
df <- read.csv(url, header = TRUE, stringsAsFactors = TRUE, encoding="UTF-8")
df
# Clean column name
df_wrangle <- df %>% dplyr::rename(Country=Country, Region=SDG.Region, Ratio=Ratio..W.M.)
df_wrangle
# Calculate Max and Min ratio for each Region
regionRatio <- df_wrangle %>%
group_by(Region) %>%
dplyr::mutate(
MaxByR = max(Ratio, na.rm = T),
MinByR = min(Ratio, na.rm = T)
) %>%
dplyr::arrange(Region)
regionRatio
# Filter the Max and Min value only, below countries will be our labels
country_label_max <- filter(regionRatio, MaxByR == Ratio)
country_label_min <- filter(regionRatio, MinByR == Ratio & Country != "Norway")
theme_opts <- theme(
text = element_text(family = "inconsolata", size = 16),
plot.title = element_text(color = "black", size = 16, face = "bold"),
plot.subtitle = element_text(color = "black", size = 12),
plot.caption = element_text(color = "#555555", size = 11),
axis.title.x = element_blank(),
# axis.title.y = element_blank(),
axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1, face = "bold"),
panel.border = element_blank(),
panel.background = element_blank(),
panel.grid.minor.x = element_blank(),
panel.grid.major.x = element_blank(),
panel.grid.minor.y = element_blank(),
#panel.grid.major.y = element_blank(),
legend.position='none'
)
region_labels <- c("Australia and\nNew Zealand",
"Central and\nSouthern Asia",
"Eastern and\nSouth-Eastern Asia",
"Europe and\nNorth America",
"Latin America and\nthe Caribbean",
"Northern Africa and\nWestern Asia",
"Oceania excl.\nAustralia and\nNew Zealand",
"Sub-Saharan Africa"
)
v1 <- ggplot(df_wrangle, aes(x = Region, y = Ratio)) +
geom_boxplot(fill = "#ACC8ED", colour = "black") +
geom_dotplot(binaxis='y', stackdir='center', dotsize = 0.3, fill="#A6609C", color="#A6609C") +
scale_x_discrete(labels = region_labels) +
scale_y_continuous(breaks = seq(0,11,1), labels = seq(0,11,1)) +
labs(
title = "Ratio of female-to-male time spent",
subtitle = "on unpaid care and domestic work by region",
x = "",
y = "ratio of female-to-male") +
theme_bw() +
theme_opts
girafe(ggobj = v1, width_svg = 16, height_svg = 9,
options = list(opts_sizing(rescale = TRUE, width = 0.8)))
v2 <- v1 +
geom_text(data = country_label_max, aes(label = Country, y = (Ratio + 0.2)), vjust = 0.0, hjust = 0.5) +
geom_text(data = country_label_min, aes(label = Country, y = (Ratio - 0.2)), vjust = 1.0, hjust = 0.5)
girafe(ggobj = v2, width_svg = 16, height_svg = 9,
options = list(opts_sizing(rescale = TRUE, width = 0.8)))
@misc{unwomen_2018_making,
author = {UN Women},
title = {MAKING EVERY WOMAN AND GIRL COUNT 2018 ANNUAL REPORT IMPLEMENTATION PHASE},
url = {https://data.unwomen.org/sites/default/files/documents/women%20count%202018%20annual%20report.pdf},
urldate = {2021-06-22},
year = {2018}
}